package com.guoyansoft.model.service.impl;

import com.guoyansoft.config.R;
import com.guoyansoft.model.dao.GoodsTypeDao;
import com.guoyansoft.model.pojo.GoodsType;
import com.guoyansoft.model.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class GoodsTypeServiceImpl implements GoodsTypeService {
    @Autowired
    private GoodsTypeDao goodsTypeDao;
    @Override
    public R queryByPage(Map<String, Object> params)  {
        List<GoodsType> empList = goodsTypeDao.selectByPage(params);
        long totalSize = goodsTypeDao.selectTotalSize(params);
        return R.suc(totalSize,empList);
    }


    @Override
    public boolean dropBatch(Integer[] ids) {
        int row = goodsTypeDao.deleteBatch(ids);
        if(row>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean save(GoodsType goodsType)  {
        int row = goodsTypeDao.insert(goodsType);
        if(row>0){
            return true;
        }
        return false;
    }


    @Override
    public boolean update(GoodsType goodsType){
        int row = goodsTypeDao.update(goodsType);
        if(row>0){
            return true;
        }
        return false;
    }

    @Override
    public GoodsType queryById(Integer id) {
        return goodsTypeDao.selectById(id);
    }

    @Override
    public R queryAll() {
        List<GoodsType> goodsTypes = goodsTypeDao.selectAll();
        return R.suc(goodsTypes);
    }
}
